import { constantRoutes, asyncRoutes } from "@/router";
export default {
  namespaced: true,
  state() {
    return {
      routes: constantRoutes,
    };
  },
  getters: {},
  mutations: {
    setRoutes(state, data) {
      state.routes = [...constantRoutes, ...data];
    },
  },
  actions: {
    filterRoutes(context, data) {
      let userAsyncRoutes = asyncRoutes.filter((item) => {
        return data.includes(item.name);
      });
      console.log(userAsyncRoutes);
      userAsyncRoutes.push({ path: "*", redirect: "/404", hidden: true });
      context.commit("setRoutes", userAsyncRoutes);
      return userAsyncRoutes;
    },
  },
};
